package com.agriculture.monitor.controller;


import com.agriculture.monitor.base.ResultInfo;
import com.agriculture.monitor.dto.DevicePage;
import com.agriculture.monitor.dto.PositionPage;
import com.agriculture.monitor.entity.Device;
import com.agriculture.monitor.entity.Position;
import com.agriculture.monitor.service.IDeviceService;
import com.agriculture.monitor.service.IPositionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2024-03-16
 */
@RestController
@RequestMapping("/device")
public class DeviceController {

    @Autowired
    IDeviceService deviceService;

    @ApiOperation(value = "保存", notes = "保存")
    @PostMapping("/save")
    public ResultInfo<?> saveData(@RequestBody Device device) {
        return ResultInfo.OK(deviceService.saveData(device));
    }

    @ApiOperation(value = "查询", notes = "查询")
    @PostMapping("/page")
    public ResultInfo<?> page(@RequestBody DevicePage devicePage) {
        return ResultInfo.OK(deviceService.listPage(devicePage));
    }

    @ApiOperation(value = "删除", notes = "删除")
    @PostMapping("/delete")
    public ResultInfo<?> remove(@RequestBody Device device) {
        return ResultInfo.OK(deviceService.removeById(device.getId()));
    }
}
